
package cc.eddic.examinationsystem.dto;

import cc.eddic.examinationsystem.domain.Option;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.val;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class OptionResponse {
    private  Long id;
    private char choice;
    private String answer;
    private boolean isCorrect;
    private Long questionId;
    public Option as(){
        return new Option(this.choice,this.answer,this.isCorrect);
    }
    public static OptionResponse from(final Option option){
        val dto=new OptionResponse();
        BeanUtils.copyProperties(option,dto);
        dto.questionId=option.getQuestion().getId();
        return dto;
    }
    public static OptionResponse from(final Option option, long id){
        val dto=new OptionResponse();
        BeanUtils.copyProperties(option,dto);
        dto.questionId=id;
        return dto;
    }
}
